# Car - By: wuhuan - 周二 11月 16 2021
import pca9685
class Car:
    def __init__(self, i2c, address=0x40, freq=10000):
        self.freq = freq
        self.pca9685 = pca9685.PCA9685(i2c, address)
        self.pca9685.freq(freq)

    def run(self,left_speed,right_speed):
        if(left_speed>0):
           self.pca9685.duty(1,0)
           self.pca9685.duty(2,4095)
        else:
           self.pca9685.duty(1,4095)
           self.pca9685.duty(2,0)
        self.pca9685.duty(0,abs(left_speed))
        if(right_speed>0):
           self.pca9685.duty(4,4095)
           self.pca9685.duty(5,0)
        else:
           self.pca9685.duty(4,0)
           self.pca9685.duty(5,4095)
        self.pca9685.duty(3,abs(right_speed))
